﻿//服务端控件ID获取
var ClientIds = getClientIds();

function saveClick() {
    $(ClientIds.hiddenSaveBtn)[0].click();
}

function setBeginDate(initDateObj) {
    var dtStr = initDateObj.value;
    var dtArr = dtStr.split("-");
    var dt = new Date(parseInt(dtArr[0]) + 1, '0', '1');

    $(ClientIds.custodyBeginDateL).html(dt.format("yyyy-MM-dd"));
    $(ClientIds.custodyBeginDate).val(dt.format("yyyy-MM-dd"));

    setCustodyEndDate($(ClientIds.custodyYear).val()); 
}

function setCustodyEndDate(custodyYear) {
    if (custodyYear == 0) {
        $(ClientIds.custodyEndDateL).html('');
        $(ClientIds.custodyEndDate).val('');
        $(ClientIds.yongjiu).html('永久');
    }else {
        var dtStr = $(ClientIds.custodyBeginDateL).html();
        var dtArr = dtStr.split("-");
        var dt = new Date(parseInt(dtArr[0]) + parseInt(custodyYear), '0', '1');
        $(ClientIds.yongjiu).html('');
        $(ClientIds.custodyEndDateL).html(dt.format("yyyy-MM-dd"));
        $(ClientIds.custodyEndDate).val(dt.format("yyyy-MM-dd"));
    }
}